{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 18.1 Definition of B-trees"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 18.1-1\n",
    "\n",
    "> Why don't we allow a minimum degree of $t = 1$?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "No key."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 18.1-2\n",
    "\n",
    "> For what values of $t$ is the tree of Figure 18.1 a legal B-tree?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2 or 3."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 18.1-3\n",
    "\n",
    "> Show all legal B-trees of minimum degree 2 that represent $\\{1, 2, 3, 4, 5\\}$."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "![](./img/18.1-3_1.png)\n",
    "\n",
    "![](./img/18.1-3_2.png)\n",
    "\n",
    "![](./img/18.1-3_3.png)\n",
    "\n",
    "\n",
    "![](./img/18.1-3_4.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 18.1-4\n",
    "\n",
    "> As a function of the minimum degree $t$, what is the maximum number of keys that can be stored in a B-tree of height $h$?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$$\n",
    "\\begin{array}{rll}\n",
    "n &=& (1 + 2t + (2t) ^ 2 + \\cdots + (2t) ^ {h}) \\cdot (2t - 1) \\\\\n",
    "&=& (2t)^{h + 1} - 1\n",
    "\\end{array}\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 18.1-5\n",
    "\n",
    "> Describe the data structure that would result if each black node in a red-black tree were to absorb its red children, incorporating their children with its own."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$t=2$, 2-3-4 tree"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
